﻿<!--TO READ THIS HELP FILE, RIGHT-CLICK ON THE FILE NAME IN THE
    SOLUTION EXPLORER PANE AND SELECT "VIEW IN BROWSER"-->

<html><head><title>Service Manager Sample</title></head><body><h1>Service Manager Sample</h1><div id="mainSection"><div id="mainBody"><div id="allHistory" class="saveHistory" onsave="saveAll()" onload="loadAll()"><font color="DarkGray"></font><p /></div><div class="introduction"><p>To get samples and instructions for installing them, see the following:</p><ul><li><p>Click <span class="ui">Samples</span> on the Visual Studio <span class="ui">Help</span> menu.</p><p>For more information, see <mshelp:link keywords="e121a9c2-b35b-4b3f-8cba-30edd84c835f" tabindex="0" xmlns:mshelp="http://msdn.microsoft.com/mshelp">Locating Sample Files</mshelp:link>.</p></li><li><p>
The most recent versions and the complete list of samples are available on the 
Visual Studio 2010 Samples Web site. </p></li><li><p>You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied to a folder under \Program Files\Visual Studio 
    10\Samples\. For Visual Studio Express Editions, all samples are located on the Internet.</p><div class="alert"><table width="100%"    IS" without warranties.</p></td></tr></table></div></li></ul></div><h3 class="procedureSubHeading">To run this sample</h3><div class="subSection"><ul><li><p>Press F5.</p>
</li>
</ul></div>
<p>
    Note: This sample requires running with Administrator permissions for some 
    operating systems (Vista or later).&nbsp; To debug the application ensure that 
    Visual Studio is started using run as Administrator.</p>
<h1 class="heading">&nbsp;</h1>
<h1 class="heading"><span   style="cursor:default;"   tabindex="0">Demonstrates</span></h1><div id="demonstratesSection" class="section" name="collapseableSection" style=""><p>Windows Services are long-running programs that perform their tasks without user interaction. This sample uses the <mshelp:link keywords="T:System.ServiceProcess.ServiceController" tabindex="0" xmlns:mshelp="http://msdn.microsoft.com/mshelp">ServiceController</mshelp:link> class from the <mshelp:link keywords="N:System.ServiceProcess" tabindex="0" xmlns:mshelp="http://msdn.microsoft.com/mshelp">System.ServiceProcess</mshelp:link> namespace. This class enables you retrieve a list of the running services through a shared method, <mshelp:link keywords="Overload:System.ServiceProcess.ServiceController.GetServices" tabindex="0" xmlns:mshelp="http://msdn.microsoft.com/mshelp">GetServices</mshelp:link>. By using the <mshelp:link keywords="T:System.ServiceProcess.ServiceController" tabindex="0" xmlns:mshelp="http://msdn.microsoft.com/mshelp">ServiceController</mshelp:link> class, you can start, stop, pause, or resume a service.</p><p>Using the user interface presented you can start, stop, pause, and resume a service. The application checks the current state of the service to see what buttons should be enabled. The <span class="ui">Relist All Services</span> command on the <span class="ui">Actions</span> menu calls the <mshelp:link keywords="Overload:System.ServiceProcess.ServiceController.GetServices" tabindex="0" xmlns:mshelp="http://msdn.microsoft.com/mshelp">GetServices</mshelp:link> method to fill the <mshelp:link keywords="T:System.Windows.Forms.ListView" tabindex="0" xmlns:mshelp="http://msdn.microsoft.com/mshelp">ListView</mshelp:link> control with the processes. The <span class="ui">Refresh</span> command on the <span class="ui">Actions</span> menu updates the status of each process already listed in the <mshelp:link keywords="T:System.Windows.Forms.ListView" tabindex="0" xmlns:mshelp="http://msdn.microsoft.com/mshelp">ListView</mshelp:link> control.</p></div></div><div id="footer"><div class="footerLine"></div><!--<include item="copyrightStatement"/>--><A NAME="feedback"></A><span id="fb" class="feedbackcss" /> 
             
                
               
                
                
               
               
               
              
                
               
              
               
               
               
         </div></div></body></html>
